import Vue from 'vue';
import Vuex from "vuex";

Vue.use(Vuex);

//全局仓储
var store = new Vuex.Store({
    state:{
        bookmarksList:[],
        createTestRequest:{
            TEST_TIME:60,
            QUESTION_NUMBER:100,
            CLASS_LIST:[],
            QUESTIONS:[]
        }
    },
    getters:{
        
    },
    actions:{
        
    },
    mutations:{  
        //增加书签
        addBookmarks(state,bookmarks){
            let index = state.bookmarksList.findIndex((item) => {
                return item.classCode === bookmarks.classCode
            })
            if(index !== -1) {
                state.bookmarksList[index].serialNo = bookmarks.serialNo
            } else {
                state.bookmarksList.push(bookmarks)
            }
        },
        setcreateTestRequest(state,rq){
            state.createTestRequest = rq;
        }
    }
});

export default store;